/* GUI CONVERTED from rccup01.p (converter v1.76) Fri May  3 13:21:02 2002 */
/* rccup01.p - Main Program for "Cum Ship Reset"                              */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8.1.7 $                                                       */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 8.5        CREATED BY:  09/26/97   BY: *J21N* Suresh Nayak       */
/* REVISION: 8.5      LAST MODIFIED: 12/01/97   BY: *J276* Suresh Nayak       */
/* REVISION: 7.4      LAST MODIFIED: 02/05/98   BY: *H1JC* Jean Miller        */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.5      LAST MODIFIED: 09/18/98   BY: *J2Q8* Patrick Rowan      */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 08/23/99   BY: *N01B* Mugdha Tambe       */
/* REVISION: 9.1      LAST MODIFIED: 11/03/99   BY: *N05R* B. Gates           */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 09/05/00   BY: *N0R9* Mudit Mehta        */
/* Revision: 1.8.1.6     BY: Jean Miller    DATE: 03/22/01 ECO: *P008*        */
/* $Revision: 1.8.1.7 $    BY: Katie Hilbert  DATE: 04/15/02 ECO: *P03J*        */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

/* PREPROCESSOR USED FOR REPORT'S WITH SIMULATION OPTION */
&SCOPED-DEFINE simulation true

{rcrpvar.i "new shared"}
define new shared variable update_yn         like mfc_logical label "Update".
define new shared variable cum_ship_start_dt as date  label "Cum Shipped Start Date".
define new shared variable remarks           as character format "x(24)"
                                             label "Remarks".
define new shared variable sortoption        as integer label "Sort Option"
                                             format "9" initial 1.
define new shared variable l_int_time        as integer no-undo.
define new shared variable l_summary         as logical format "Summary/Detail"
                                             label "Report Summary/Detail" no-undo.
define new shared variable l_dt_ship_eff     as logical format "Shipment/Effective"
                                             label "Shipment/Effective Date" no-undo.
define new shared variable l_cum_adj         like mfc_logical initial "yes"
                                             label "Include Manual Cum Adjustment" no-undo .

define variable sortextoption  as character extent 2 format "x(66)".
define variable l_start_time   as character format "xx:xx"
                               label "Start Time" no-undo.
define variable l_dummy_length as character format "999:99" no-undo.
define variable l_msgnbr       as integer no-undo.
define variable l_ref_time     as character format "99:99" no-undo.

sortextoption[1] = "1 - " + getTermLabel("BY_SHIP-FROM",12)      + "," +
                            getTermLabel("CUSTOMER",4)           + "," +
                            getTermLabel("SHIP-TO",7)            + "," +
                            getTermLabel("ORDER",5)              + "," +
                            getTermLabel("DOCK",4)               + "," +
                            getTermLabel("ITEM",4)               + "," +
                            getTermLabel("PURCHASE_ORDER",2)     + "," +
                            getTermLabel("CUSTOMER_REFERENCE",8) + "," +
                            getTermLabel("MODEL_YEAR",8).
sortextoption[2] = "2 - " + getTermLabel("BY_SHIP-FROM",12)      + "," +
                            getTermLabel("ITEM",4)               + "," +
                            getTermLabel("CUSTOMER",4)           + "," +
                            getTermLabel("SHIP-TO",7)            + "," +
                            getTermLabel("ORDER",5)              + "," +
                            getTermLabel("DOCK",4)               + "," +
                            getTermLabel("PURCHASE_ORDER",2)     + "," +
                            getTermLabel("CUSTOMER_REFERENCE",8) + "," +
                            getTermLabel("MODEL_YEAR",8).

assign
   l_summary = true
   l_dt_ship_eff = true.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
shipfrom_from     colon 15 label "Ship-From"
   shipfrom_to       colon 47 label {t001.i}
   cust_from         colon 15
   cust_to           colon 47 label {t001.i}
   shipto_from       colon 15
   shipto_to         colon 47 label {t001.i}
   dock_from         colon 15
   dock_to           colon 47 label {t001.i}
   part_from         colon 15
   part_to           colon 47 label {t001.i}
   po_from           colon 15 format "x(22)"
   po_to             colon 47 label {t001.i} format "x(22)"
   custref_from      colon 15 format "x(22)"
   custref_to        colon 47 label {t001.i} format "x(22)"
   modelyr_from      colon 15
   modelyr_to        colon 47 label {t001.i} format "x(4)"
   order_from        colon 15
   order_to          colon 47 label {t001.i}
   update_yn         colon 15
   l_dt_ship_eff     colon 55
   cum_ship_start_dt at     4
   l_start_time      at    45
   l_cum_adj         at     4
   l_summary         at     4
   remarks           at    45
   sortoption        colon 15
   sortextoption[1]  at 7    no-label
   sortextoption[2]  at 7    no-label
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/*V8+*/

cum_ship_start_dt = today.

repeat:

   display
      sortextoption
   with frame a.

   if shipfrom_to = hi_char then shipfrom_to = "".
   if cust_to     = hi_char then cust_to     = "".
   if shipto_to   = hi_char then shipto_to   = "".
   if dock_to     = hi_char then dock_to     = "".
   if part_to     = hi_char then part_to     = "".
   if po_to       = hi_char then po_to       = "".
   if custref_to  = hi_char then custref_to  = "".
   if modelyr_to  = hi_char then modelyr_to  = "".
   if order_to    = hi_char then order_to    = "".

   update
      shipfrom_from
      shipfrom_to
      cust_from
      cust_to
      shipto_from
      shipto_to
      dock_from
      dock_to
      part_from
      part_to
      po_from
      po_to
      custref_from
      custref_to
      modelyr_from
      modelyr_to
      order_from
      order_to
      update_yn
      l_dt_ship_eff
      cum_ship_start_dt
      l_start_time
      l_cum_adj
      l_summary
      remarks
      sortoption
   with frame a.

   bcdparm = "".

   {mfquoter.i shipfrom_from}
   {mfquoter.i shipfrom_to }
   {mfquoter.i cust_from   }
   {mfquoter.i cust_to     }
   {mfquoter.i shipto_from }
   {mfquoter.i shipto_to   }
   {mfquoter.i dock_from   }
   {mfquoter.i dock_to     }
   {mfquoter.i part_from   }
   {mfquoter.i part_to     }
   {mfquoter.i po_from     }
   {mfquoter.i po_to       }
   {mfquoter.i custref_from}
   {mfquoter.i custref_to  }
   {mfquoter.i modelyr_from}
   {mfquoter.i modelyr_to  }
   {mfquoter.i order_from  }
   {mfquoter.i order_to    }
   {mfquoter.i update_yn   }
   {mfquoter.i l_dt_ship_eff}
   {mfquoter.i cum_ship_start_dt}
   {mfquoter.i l_start_time}
   {mfquoter.i l_cum_adj   }
   {mfquoter.i l_summary   }
   {mfquoter.i Remarks     }
   {mfquoter.i sortoption  }

   if shipfrom_to = "" then shipfrom_to = hi_char.
   if cust_to     = "" then cust_to     = hi_char.
   if shipto_to   = "" then shipto_to   = hi_char.
   if dock_to     = "" then dock_to     = hi_char.
   if part_to     = "" then part_to     = hi_char.
   if po_to       = "" then po_to       = hi_char.
   if custref_to  = "" then custref_to  = hi_char.
   if modelyr_to  = "" then modelyr_to  = hi_char.
   if order_to    = "" then order_to    = hi_char.

   /* Add this do loop so the converter wont create an 'on leave' */
   do:

      if cum_ship_start_dt = ? then do:
         {pxmsg.i &MSGNUM=27 &ERRORLEVEL=3} /* INVALID DATE */
         next-prompt cum_ship_start_dt with frame a.
         undo, retry.
      end. /* END OF IF cum_ship_start_dt = ? */

      if cum_ship_start_dt:SCREEN-VALUE in frame a <> string(today)
         and l_start_time = ""
      then do:
         l_start_time = "0000" .
         display l_start_time with frame a.
      end.

      if not (l_dt_ship_eff) and l_start_time <> "0000"
      then do:
         l_start_time = "0000" .
         display
            l_start_time
         with frame a.
         {pxmsg.i &MSGNUM=4302 &ERRORLEVEL=2}
         /* STARTING TIME CANNOT BE USED WITH
            EFFECTIVE DATE, SETTING TO 00:00 */
      end.

      l_ref_time = substring(string(time,"HH:MM"),1,2)
                 + substring(string(time,"HH:MM"),4,2).

      /* FSTIMCHK WILL RETURN ONE OF TWO POTENTIAL  */
      /* ERRORS.  #30 IS FOR MINUTES > 59.  #69     */
      /* INDICATES NON-NUMERIC INPUT, IN WHICH CASE */
      /* WE WANT TO PRESERVE AND REDISPLAY THE USER */
      /* INPUT.                                     */
      {gprun.i ""fstimchk.p""
         "(input  ""T"",
           input  l_start_time,
           input  """",
           output l_ref_time,
           output l_dummy_length,
           output l_msgnbr)"}

      if l_msgnbr <> 69 and input l_start_time <> "" then
         assign l_start_time = string(l_ref_time).

      if l_msgnbr <> 0 then do:
         {pxmsg.i &MSGNUM=l_msgnbr &ERRORLEVEL=3}
         next-prompt l_start_time with frame a.
         undo, retry.
      end. /* END OF IF l_msgnbr <> 0 */

      l_int_time =
         (integer(substring(l_start_time,1,2)) * 3600
        + integer(substring(l_start_time,3,2)) * 60) .

   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer"
               &printWidth = 132
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "yes"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


   {mfphead.i}

   if sortoption = 1 then do:
      {gprun.i ""rccupa.p""}
   end.

   else if sortoption = 2 then do:
      {gprun.i ""rccupb.p""}
   end.

   /* REPORT TRAILER */
   {mfrtrail.i}

end. /* END OF REPEAT */
